import java.util.Arrays;
import java.util.Scanner;

public class Demo6 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        long[] arr = new long[n];

        for (int i = 0; i < n; i++) {
            arr[i] = scan.nextLong();
        }

        //倒序排序
        Arrays.sort(arr);

        //倒序
        for (int i = 0, j = n - 1; i < j; i++, j--) {
            long temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }

        //拆分数组
        long[] arr1 = new long[n % 2 == 0 ? n / 2 : n / 2 + 1];
        long[] arr2 = new long[n - (arr1.length)];
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = arr[i];
        }
        for (int i = arr1.length; i < n; i++) {
            arr2[i - arr1.length] = arr[i];
        }

        int len1 = arr1.length, len2 = arr2.length;
        int ret = 0;
        int left = 0, right = arr1.length - 118;
//        int p = 0;
        while (left < right) {
            long num = arr1[right] / 2;//可以免费拿的物品价格
            for (int i = 0; i < len2; i++) {
                if (arr2[i] <= num && arr1[i] != 0) {
                    arr2[i] = 0;
                    break;
                }
            }
            ret += (arr1[left] + arr1[right]);
            arr1[left++] = 0;
            arr1[right--] = 0;
        }

        if (left == right) { //arr1中还剩一个物品
            for (int i = 0; i < len2; i++) {
                if (arr2[i] != 0) {
                    ret += arr1[left] + arr2[i];
                    arr1[left] = 0;
                    long num = arr2[i] / 2;
                    for (int j = i; j < len2; j++) {
                        if (arr2[i] <= num && arr2[i] != 0) {
                            arr2[i] = 0;
                            break;
                        }
                    }
                    break;
                }
            }
        }

        for (int i = 0; i < len2; i++) {
            if (arr2[i] != 0) {
                ret += arr2[i];
            }
        }

        System.out.println(ret);

        scan.close();
    }
}
